package com.bytz.modules.cms.pay.chinapay.util;

import cn.hutool.core.map.MapUtil;
import com.bytz.modules.cms.order.model.PayResponse;
import com.bytz.modules.cms.order.model.PayResponseStatus;

import java.util.Map;

/**
 * ChinaPay支付响应工具类
 * @author shanxuezhong
 */
public class ChinaPayResponseUtil {
    private static final Map<String, PayResponse> RESPONSE_MAP;

    public static PayResponse getPayResponse(String code) {
        return RESPONSE_MAP.get(code);
    }

    static {
        RESPONSE_MAP = MapUtil.newHashMap(140);
        RESPONSE_MAP.put("0000", new PayResponse("0000", "成功", PayResponseStatus.Succeed));
        RESPONSE_MAP.put("0001", new PayResponse("0001", "初始状态",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("0003", new PayResponse("0003", "消费交易失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("0006", new PayResponse("0006", "签约失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("0007", new PayResponse("0007", "重复签约",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("0009", new PayResponse("0009", "退款交易失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("0012", new PayResponse("0012", "交易撤销成功",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("0014", new PayResponse("0014", "数据接收成功",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("0024", new PayResponse("0024", "退款撤销成功",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("0025", new PayResponse("0025", "重复交易",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("0026", new PayResponse("0026", "预授权完成处理成功",  PayResponseStatus.Succeed));
        RESPONSE_MAP.put("0029", new PayResponse("0029", "预授权撤销成功",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("0031", new PayResponse("0031", "退款撤销审核不通过",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("0037", new PayResponse("0037", "预授权完成撤销成功",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("1002", new PayResponse("1002", "商户审核不通过",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("1003", new PayResponse("1003", "商户已审核",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1005", new PayResponse("1005", "交易撤销中",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1007", new PayResponse("1007", "退款撤销中",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1008", new PayResponse("1008", "预授权完成处理中",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1009", new PayResponse("1009", "预授权撤销中",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1010", new PayResponse("1010", "重汇已申请",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1011", new PayResponse("1011", "重汇审核通过",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1012", new PayResponse("1012", "重汇审核不通过",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("1013", new PayResponse("1013", "退款成功(重汇)",  PayResponseStatus.Succeed));
        RESPONSE_MAP.put("1014", new PayResponse("1014", "预授权完成撤销中",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1015", new PayResponse("1015", "交易发送成功",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1016", new PayResponse("1016", "交易发送失败",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1017", new PayResponse("1017", "初始发送状态",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1018", new PayResponse("1018", "生成支付账单号成功",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1019", new PayResponse("1019", "经办成功",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1021", new PayResponse("1021", "单边账已退款",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("1022", new PayResponse("1022", "商户已申请",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1026", new PayResponse("1026", "退款调账已申请",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1027", new PayResponse("1027", "退款调账成功",  PayResponseStatus.Succeed));
        RESPONSE_MAP.put("1028", new PayResponse("1028", "重汇文件已下载",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1029", new PayResponse("1029", "重汇确认失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("1030", new PayResponse("1030", "财务已审核",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1049", new PayResponse("1049", "退款预终止",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("1050", new PayResponse("1050", "退款已终止",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("1099", new PayResponse("1099", "风险交易（渠道应答中部分信息与请求不符）",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("2001", new PayResponse("2001", "报文解析失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2002", new PayResponse("2002", "无效的令牌",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2003", new PayResponse("2003", "卡已过期",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2004", new PayResponse("2004", "请求频繁",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2006", new PayResponse("2006", "交易超时",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("2007", new PayResponse("2007", "获取动态验证码失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2015", new PayResponse("2015", "IP 地址非法",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2016", new PayResponse("2016", "非法服务请求",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2017", new PayResponse("2017", "平台校验失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2018", new PayResponse("2018", "无效证书",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2027", new PayResponse("2027", "商户支付机构信息表无记录",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2028", new PayResponse("2028", "查询系统配置表无记录",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2031", new PayResponse("2031", "非法商户",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2032", new PayResponse("2032", "CVN2 失效",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2034", new PayResponse("2034", "重复退款",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2036", new PayResponse("2036", "交易报文信息不一致",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2040", new PayResponse("2040", "订单数据已同步，请至新菜单做退款",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2042", new PayResponse("2042", "格式校验失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2043", new PayResponse("2043", "系统异常，请查询后处理",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("2044", new PayResponse("2044", "基本格式检验失败-字段非空未填",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2045", new PayResponse("2045", "基本格式检验失败-字段类型错误",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2046", new PayResponse("2046", "基本格式检验失败-字段长度错误",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2049", new PayResponse("2049", "风控受限",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2061", new PayResponse("2061", "银行卡非法",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2064", new PayResponse("2064", "资金不足",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2066", new PayResponse("2066", "手机号已失效",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2067", new PayResponse("2067", "手机号格式错误",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2071", new PayResponse("2071", "无效短信码",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("2402", new PayResponse("2402", "原交易判定失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3003", new PayResponse("3003", "验签失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3004", new PayResponse("3004", "防钓鱼校验失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3007", new PayResponse("3007", "订单有效期失效",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3010", new PayResponse("3010", "商户未开通此交易类型",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3011", new PayResponse("3011", "单笔交易超限",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3012", new PayResponse("3012", "累计交易笔数超限",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3013", new PayResponse("3013", "累计交易金额超限",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3014", new PayResponse("3014", "单笔交易超限-商户",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3015", new PayResponse("3015", "累计交易笔数超限-商户",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3016", new PayResponse("3016", "累计交易金额超限-商户",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3019", new PayResponse("3019", "分账方和订单商户非分账关系",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3020", new PayResponse("3020", "分账金额与订单金额不符",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3022", new PayResponse("3022", "该笔订单已经支付成功请查实",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3034", new PayResponse("3034", "未找到原始交易",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3201", new PayResponse("3201", "查发卡方",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3229", new PayResponse("3229", "不正确的 PIN",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3233", new PayResponse("3233", "受限制的卡",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3239", new PayResponse("3239", "允许的输入 PIN 次数超限",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3249", new PayResponse("3249", "交换中心转发了原交易请求，但未收到发卡方应答",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("3251", new PayResponse("3251", "受理方状态非法",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3264", new PayResponse("3264", "已发送银行",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("3270", new PayResponse("3270", "不支持此类卡交易",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3285", new PayResponse("3285", "预授权号不匹配",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3289", new PayResponse("3289", "预授权完成金额不匹配",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3290", new PayResponse("3290", "预授权取消、完成交易不得超过原交易 30 天以上",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3293", new PayResponse("3293", "交易结果未知",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("3295", new PayResponse("3295", "累计退货金额大于原交易金额",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3302", new PayResponse("3302", "卡号与证件号码不符",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3305", new PayResponse("3305", "该储种不能办理代收付业务",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3308", new PayResponse("3308", "账户状态不正常",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3309", new PayResponse("3309", "帐户已销户",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3310", new PayResponse("3310", "账户已冻结",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3325", new PayResponse("3325", "密码错误",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3326", new PayResponse("3326", "户名不符",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3333", new PayResponse("3333", "原交易信息记录不存在",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3346", new PayResponse("3346", "银行分户存款余额不足",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3359", new PayResponse("3359", "交易提交银行错误请与 ChinaPay 系统管理员联系",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3389", new PayResponse("3389", "密码输错次数超限，请联系发卡行",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3397", new PayResponse("3397", "未开通银联无卡支付业务",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3400", new PayResponse("3400", "路由失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3401", new PayResponse("3401", "地区信息错误",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3417", new PayResponse("3417", "签名错误",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3422", new PayResponse("3422", "撤销交易的日期不是当天的日期",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3427", new PayResponse("3427", "交易金额超出待支付金额",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3432", new PayResponse("3432", "处理失败",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3441", new PayResponse("3441", "无流水",  PayResponseStatus.Paying));
        RESPONSE_MAP.put("3444", new PayResponse("3444", "商户日期与系统日期相差超过一天，拒绝交易",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3445", new PayResponse("3445", "交易币种非法",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3446", new PayResponse("3446", "原交易已做过退款，撤销拒绝",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3448", new PayResponse("3448", "授权码校验不一致",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3450", new PayResponse("3450", "退款交易状态非失败，退款撤销拒绝",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3452", new PayResponse("3452", "商户未配置所属收单机构",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3455", new PayResponse("3455", "商户未关联分账商户",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3456", new PayResponse("3456", "该商户不是分账商户",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3458", new PayResponse("3458", "商户费用分账数据未配置",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3459", new PayResponse("3459", "分账数据错误",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3460", new PayResponse("3460", "分账订单已分账",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3461", new PayResponse("3461", "非延时分账交易",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3462", new PayResponse("3462", "非分账交易",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3463", new PayResponse("3463", "批量-明细信息不匹配",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("4364", new PayResponse("4364", "支付机构号不支持前台交易",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3468", new PayResponse("3468", "商户未关联在该接入机构下",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3470", new PayResponse("3470", "未查询到签约信息或签约信息已变更",  PayResponseStatus.Failed));
        RESPONSE_MAP.put("3473", new PayResponse("3473", "渠道无流水",  PayResponseStatus.Failed));
    }

}
